using System;

namespace AeonOfStrifeDatatypes.Combat
{
	public struct DamageValues
	{
		public int Slash { get; set; }

		public int Pierce { get; set; }

		public int Crush { get; set; }

		public int Elemental { get; set; }

		public int Dark { get; set; }

		public int Body { get; set; }

		/// <summary>
		///	takes in any number of DamageValues, sums them and returns the result
		/// </summary>
		/// <param name="p_values">a variable number of DamageValues objects</param>
		/// <returns>the sum of all DamageValues passed</returns>
		public static DamageValues Add(params DamageValues[] p_values) {
			var returnVal = new DamageValues();

			foreach(var value in p_values) {
				returnVal.Slash += value.Slash;
				returnVal.Pierce += value.Pierce;
				returnVal.Crush += value.Crush;
				returnVal.Elemental += value.Elemental;
				returnVal.Dark += value.Dark;
				returnVal.Body += value.Body;
			}

			return returnVal;
		}

		public static int GetResolvedCombatDamage(DamageValues p_defense, DamageValues p_damage) {
			float damageDealt = 0f;
			damageDealt += p_damage.Slash * (p_defense.Slash / 100f);
			damageDealt += p_damage.Crush * (p_defense.Crush / 100f);
			damageDealt += p_damage.Pierce * (p_defense.Pierce / 100f);
			damageDealt += p_damage.Body * (p_defense.Body / 100f);
			damageDealt += p_damage.Elemental * (p_defense.Elemental / 100f);
			damageDealt += p_damage.Dark * (p_defense.Dark / 100f);
			return (int)Math.Ceiling(damageDealt);
		}
	}
}